package mars.activity;

import java.util.ArrayList;
import java.util.HashMap;
import bear.download.Userread;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;

public class shareActivity extends ListActivity{
private Button newtext,turnup2,turndown2;
private TextView pages2;
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.share);
		newtext=(Button)findViewById(R.id.newtext);
		turnup2=(Button)findViewById(R.id.turnup2);
		turndown2=(Button)findViewById(R.id.turndown2);
		pages2=(TextView)findViewById(R.id.pages2);
		
		
		String loushinames[] = Userread.loushiname1.split("\\$");
		String contents[] = Userread.content1.split("\\$");
		String times[] = Userread.time1.split("\\$");
		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		for(int i=0;i<Userread.n;i++){
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("name", loushinames[i]);
		map.put("time", times[i]);
		map.put("content", contents[i]);
		list.add(map);
		}
		SimpleAdapter listAdapter = new SimpleAdapter(shareActivity.this, list,
				R.layout.bookapp, new String[] { "name", "time","content"},
				new int[] { R.id.text7,R.id.time,R.id.mycontent});
		setListAdapter(listAdapter);
		pages2.setText("1/1");
		
		turnup2.setOnClickListener(new Button.OnClickListener()
	    {
			public void onClick(View v) {
				// TODO Auto-generated method stub;
				Toast.makeText(shareActivity.this, R.string.up0,Toast.LENGTH_LONG).show();
			}	
	    });
		turndown2.setOnClickListener(new Button.OnClickListener()
	    {
			public void onClick(View v) {
				// TODO Auto-generated method stub;
				Toast.makeText(shareActivity.this, R.string.down0,Toast.LENGTH_LONG).show();
			}	
	    });
	       
	newtext.setOnClickListener(new Button.OnClickListener()
    {
		public void onClick(View v) {
			// TODO Auto-generated method stub
			Intent intent=new Intent();
			intent.setClass(shareActivity.this, newtextActivity.class);
			shareActivity.this.startActivity(intent);
		}	
    });	
	}
	protected void onListItemClick(ListView l, View v, int position, long id) {
		// TODO Auto-generated method stub
		super.onListItemClick(l, v, position, id);
		//System.out.println("id----------------" + id);
		//System.out.println("position----------" + position);
	}
}
